#ifndef COMPONENTDETAILPAGE_H
#define COMPONENTDETAILPAGE_H

#include <QWidget>
#include "../backend/component.h" // Full definition for easy access in .cpp

// Qt UI 元素的向前声明
class QLabel;
class QPushButton;
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QScrollArea;

class ComponentDetailPage : public QWidget {
    Q_OBJECT

public:
    explicit ComponentDetailPage(QWidget *parent = nullptr);
    ~ComponentDetailPage();

    // 使用新数据更新页面的方法，现在包括供应商名称
    void loadComponentData(const Component* componentData, const QString& supplierName);

signals:
    void backToMainRequested(); // Signal to notify MainWindow to go back

private slots:
    void onInternalBackButtonClicked(); // Slot for the back button on this page

private:
    void setupUserInterface();
    void clearPageContent(); // Helper to clear old data

    // UI 元素
    QLabel* imageLabel; // For displaying component image (or placeholder)
    
    // 基本信息部分
    QLabel* modelValueLabel;
    QLabel* brandValueLabel;
    QLabel* categoryValueLabel;
    QLabel* packageValueLabel;
    QLabel* supplierValueLabel;
    QLabel* stockValueLabel;

    // 各部分的标题
    QLabel* basicInfoTitleLabel; // Title for Basic Info section
    QLabel* specsTitleLabel;     // Title for Specifications section
    QLabel* packageInfoTitleLabel; // Title for Package Info section

    // 规格参数部分（动态填充）
    QGridLayout* specsLayout;
    QWidget* specsContainerWidget; 

    // 封装信息部分（动态填充或静态）
    QGridLayout* packageInfoLayout;
    QWidget* packageInfoContainerWidget;

    QPushButton* internalBackButton; // "返回" button

    // 布局
    QVBoxLayout* mainLayout;         
    QHBoxLayout* topContentLayout;   
    QVBoxLayout* rightInfoPanelLayout; 
    QScrollArea* scrollArea;         
    QWidget* scrollAreaWidgetContents; 
};

#endif // COMPONENTDETAILPAGE_H